weights = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2]

check = ['1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2']

n = int(input())
res = []

for j in range(n):
    str = input().strip()

    if not str[:17].isdigit():
        res.append(str)
        continue

    total = 0
    for i in range(17):
        total += int(str[i]) * weights[i]

    z = total % 11
    temp = check[z]

    if str[17] != temp:
        res.append(str)

if not res:
    print("All passed")
else:
    for id in res:
        print(id)